import type { App } from 'vue'
import { createPinia } from 'pinia'
// 持久化
import piniaPluginPersist from 'pinia-plugin-persist'
// 导入不同的模块
import useAppStore from '@/stores/modules/app'
import useSettingsStore from '@/stores/modules/settings'
import useUserInfoStore from '@/stores/modules/userInfo'
import useTreeTable from '@/stores/modules/useTreeTable'
// 表格的仓库
import useTable from '@/stores/modules/useTable'

const store = createPinia()
// 持久化
store.use(piniaPluginPersist)
export function setupStore(app: App<Element>) {
  app.use(store)
}
export { store }

// 定义一个函数,并把不同模块的仓库导入进去
const useStore = () => {
  return {
    App: useAppStore(),
    Setting: useSettingsStore(),
    UserInfo: useUserInfoStore(),
    useTable: useTable(),
    useTreeTable: useTreeTable()
  }
}
// 导出
export default useStore
